<template>
  <div>
    <div slot="header" class="clearfix" style="text-align: center;line-height: 30px">
      <h3>促销方案审核</h3>
    </div>

    <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
      <el-row>
        <el-col :span="12">
          <el-form-item label="促销商品编号">
            <el-input v-model="upod"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="促销商品名称">
            <el-input v-model="goodsname"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="促销商品价格">
            <el-input v-model="discountprice"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="促销方案说明">
            <el-input v-model="saleinfo"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12" style="text-align: center">
          <el-button type="primary" @click="passAudit" >通过审核</el-button>
        </el-col>
        <el-col :span="12" style="text-align: center">
          <el-button type="primary" @click="noPassAudit">不通过</el-button>
        </el-col>
      </el-row>

    </el-form>
  </div>
</template>

<script>
export default {
  name: "SsalegoodsdecisionLook",
  props:{
    usercodeTag:String
  },
  data(){
    return{
      upod:'',
      goodsname:'',
      discountprice:'',
      saleinfo:''
    }
  },
  mounted() {
    this.init(this.usercodeTag)
  },
  methods:{
    init(tag){
      let url = '/csc/salegoodsdecision/bySaleGoodsIdGetSaleGoods/'+tag
      this.$axios.get(url).then(r=>{
        console.log(this.usercodeTag+'=======================')
        console.log(r.data)
        this.upod = r.data.upod
        this.goodsname = r.data.goodsname
        this.discountprice = r.data.discountprice
        this.saleinfo = r.data.saleinfo
      })
    },
    passAudit(){
      this.$confirm('确定通过审核?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url = '/csc/salegoodsdecision/uptateSalegoodsdecision/1/'+this.usercodeTag
        this.$axios.get(url).then(r=>{
          this.$message.success(r.data)
          this.$emit("initDialog")
          this.$emit("closeDialog")
          this.$router.push("Ssalegoodsdecision")
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    noPassAudit(){
      this.$confirm('确定不通过审核?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url = '/csc/salegoodsdecision/uptateSalegoodsdecision/2/'+this.usercodeTag
        this.$axios.get(url).then(r=>{
          this.$message.success(r.data)
          this.$emit("initDialog")
          this.$emit("closeDialog")
          this.$router.push("Ssalegoodsdecision")
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    }
  }
}
</script>

<style scoped>

</style>